Application needs to get the Tags from the Dll which are reported by Reader. Tags can be reported as part of an Inventory operation (rfid3.Actions.Inventory.Perform) or a Read Access operation (rfid3.Actions.TagAccess.ReadEvent or rfid3.Actions.TagAccess.ReadWait).
Applications can also configure to receive Tag reports that indicate the results of access operations as shown beneath.
TagStorageSettings
tagStorageSettings = rfid3.Config.GetTagStorageSettings();
tagStorageSettings.EnableAccessReports
= true;
rfid3.Config.SetTagStorageSettings(tagStorageSettings);
Each Tag has a set of associated information along with it. During Inventory operation the Reader reports the EPC-ID of the Tag where as during Read-Access operation the requested Memory Bank Data is also reported apart from EPC-ID. In either case, there is additional information like PC-bits, RSSI, last time seen, tag seen count, etc that will be available for each Tag. This information is reported to the Application as TagData for each Tag reported by the Reader.
The Application can specify its customized memory bank data size using the function rfid3.Config.SetTagStorageSettings. The Application shall initialize the tag storage settings for TagData so that all Tag allocations reflect the applications customized memory requirement.
TagStorageSettings tagStorageSettings = new TagStorageSettings(100, 512, 512);
rfid3.Config.SetTagStorageSettings(tagStorageSettings);
Applications can also choose to enable/disable reporting of certain fields in TAG_DATA. Disabling certain fields can sometimes improve the performance as the Reader and the Dll shall not be processing that information. It can also result in specific behavior. For e.g. disabling reporting of Antenna Id can result in application receiving as single unique tag even though they were multiple entries of the same tag reported from different Antennas. The following snippet shows enabling the reporting of PeakRSSI, Tag Seen count, PC and CRC only and diabling other fields like Antenna ID, time stamps and XPC.
TagStorageSettings
tagStorageSettings = rfid3.Config.GetTagStorageSettings();
tagStorageSettings.TagFields
= TAG_FIELD.PC | TAG_FIELD.PEAK_RSSI | TAG_FIELD.TAG_SEEN_COUNT |
TAG_FIELD.CRC;
rfid3.Config.SetTagStorageSettings(tagStorageSettings);
Following are few use-cases that get Tags from the Reader:
Inventory operation: When RFID rfid3.Actions.Inventory.Perform is invoked, the application will get notified of ReadNotify if tags are reported back from the Reader if registered for read notification. When notified of the same, the event argument contains the tag data.
TagData.OpCode for inventory operation will be ACCESS_OPERATION_NONE, and TagData.OpStatus to be ignored.
// Simple Inventory with tag events
rfid3.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
TagData reportedTag = new TagData();
rfid3.Actions.Inventory.Perform();
Thread.Sleep(1000);
rfid3.Actions.Inventory.Stop();
// Read Notify Event handler
public void Events_ReadNotify(object sender, Events.ReadEventArgs e)
{
Console.WriteLine(e.ReadEventData.TagData.TagID);
if (e.ReadEventData.TagData.OpCode == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ &&
e.ReadEventData.TagData.OpStatus == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS)
Console.WriteLine(e.ReadEventData.TagData.MemoryBank.ToString()+
" : " + e.ReadEventData.TagData.MemoryBankData);
}
Application can call GetReadTags method to fetch tags from the Dll by specifying the number of expected tags.
// Simple Inventory operation for 1 seconds and get the tags
// with GetReadTags method
rfid3.Actions.Inventory.Perform();
Thread.Sleep(1000);
rfid3.Actions.Inventory.Stop();
TagData[] remainingTags = rfid3.Actions.GetReadTags(100);
for(int nIndex = 0; nIndex < remainingTags.Length; nIndex++)
{
Console.WriteLine(remainingTags[nIndex].TagID);
}
Single Tag Read Access: When the application calls the method rfid3.Actions.TagAccess.ReadWait to read data from a specific memory bank of a particular tag, the method returns the TagData for which TagData.OpCode will be ACCESS_OPERATION_READ, and TagData.OpStatus indicating the result of the operation; if TagData.OpStatus is ACCESS_SUCCESS, the requested memory bank data can be found in TagData.MemoryBankData.
/*Simple Read Access Operation on Specific Tag*/
string tagId = "1234ABCD00000000000025B1";
TagAccess.ReadAccessParams readParams = new TagAccess.ReadAccessParams();
TagData readAccessTag;
readParams.AccessPassword = 0;
readParams.ByteCount = 8;
readParams.MemoryBank = MEMORY_BANK.MEMORY_BANK_USER;
readParams.ByteOffset = 0;
readAccessTag = rfid3.Actions.TagAccess.ReadWait(tagId, readParams, null);
Console.WriteLine(readAccessTag.MemoryBank.ToString() + " : " + readAccessTag.MemoryBankData);
Multiple Tags Read Access: When the application calls the method rfid3.Actions.TagAccess.ReadEvent to read data from a specific memory bank of multiple tags, the method returns immediately, and reports the Tags asynchronously as done in Inventory operation. Tags reported as part of read access operation will have TagData.OpCode as ACCESS_OPERATION_READ, and TagData.OpStatus indicating the result of the operation; if TagData.OpStatus is ACCESS_SUCCESS, the requested memory bank data can be found in TagData.MemoryBankData.
/*Simple Access Operation on Multiple Tags*/
AutoResetEvent AccessComplete;
AccessComplete = new AutoResetEvent(false);
rfid3.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
rfid3.Events.NotifyInventoryStartEvent = true;
rfid3.Events.NotifyInventoryStopEvent = true;
rfid3.Events.NotifyAccessStartEvent = true;
rfid3.Events.NotifyAccessStopEvent = true;
rfid3.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
TagData reportedTag = new TagData();
TagAccess.ReadAccessParams readParams = new TagAccess.ReadAccessParams();
readParams.AccessPassword = 0;
readParams.ByteCount = 0;
readParams.MemoryBank = MEMORY_BANK.MEMORY_BANK_USER;
readParams.ByteOffset = 0;
rfid3.Actions.TagAccess.ReadEvent(readParams, null, null);
AccessComplete.WaitOne(4000, false);
Access Operation Sequence Read Access: When the application calls the method rfid3.Actions.TagAccess.OperationSequence.PerformSequence further to adding operations for Read (using rfid3.Actions.TagAccess.OperationSequence.Add of ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ), the method rfid3.Actions.TagAccess.OperationSequence.PerformSequence returns immediately, and reports tags asynchronously.
/*Access Sequence Operation reads all memory banks */
rfid3.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
TagAccess.Sequence.Operation op1 = new TagAccess.Sequence.Operation();
op1.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;
op1.ReadAccessParams.MemoryBank = MEMORY_BANK.MEMORY_BANK_RESERVED;
op1.ReadAccessParams.ByteCount = 0;
op1.ReadAccessParams.ByteOffset = 0;
op1.ReadAccessParams.AccessPassword = 0;
rfid3.Actions.TagAccess.OperationSequence.Add(op1);
TagAccess.Sequence.Operation op2 = new TagAccess.Sequence.Operation();
op2.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;
op2.ReadAccessParams.MemoryBank = MEMORY_BANK.MEMORY_BANK_EPC;
op2.ReadAccessParams.ByteCount = 0;
op2.ReadAccessParams.ByteOffset = 0;
op2.ReadAccessParams.AccessPassword = 0;
rfid3.Actions.TagAccess.OperationSequence.Add(op2);
TagAccess.Sequence.Operation op3 = new TagAccess.Sequence.Operation();
op3.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;
op3.ReadAccessParams.MemoryBank = MEMORY_BANK.MEMORY_BANK_TID;
op3.ReadAccessParams.ByteCount = 0;
op3.ReadAccessParams.ByteOffset = 0;
op3.ReadAccessParams.AccessPassword = 0;
rfid3.Actions.TagAccess.OperationSequence.Add(op3);
TagAccess.Sequence.Operation op4 = new TagAccess.Sequence.Operation();
op4.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;
op4.ReadAccessParams.MemoryBank = MEMORY_BANK.MEMORY_BANK_USER;
op4.ReadAccessParams.ByteCount = 0;
op4.ReadAccessParams.ByteOffset = 0;
op4.ReadAccessParams.AccessPassword = 0;
rfid3.Actions.TagAccess.OperationSequence.Add(op4);
rfid3.Actions.TagAccess.OperationSequence.PerformSequence();
/* performs only for 2000 seconds.. */
Thread.Sleep(2000);
rfid3.Actions.TagAccess.OperationSequence.StopSequence();